<?php
declare(strict_types=1);
namespace Field;

class StoreVoucherConst
{
    public const pk='VoucherID';
    public const index=['VoucherID'];
	public const fields=['VoucherID','Title','IsDelete','RuleID','TimeAdd','ProductID','Price'];
	public const comment=['VoucherID'=>'抵用券ID','Title'=>'名称','IsDelete'=>'是否删除','RuleID'=>'规则 1 加时间 101 转移授权时间','TimeAdd'=>'增加时间','ProductID'=>'商品ID','Price'=>'价值'];
	/*
    * @Field VoucherID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 抵用券ID
    */
    public const VoucherID = 'VoucherID';
    /*
    * @Field Title
    * @Type char(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 名称
    */
    public const Title = 'Title';
    /*
    * @Field IsDelete
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 是否删除
    */
    public const IsDelete = 'IsDelete';
    /*
    * @Field RuleID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 规则 1 加时间 101 转移授权时间
    */
    public const RuleID = 'RuleID';
    /*
    * @Field TimeAdd
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 增加时间
    */
    public const TimeAdd = 'TimeAdd';
    /*
    * @Field ProductID
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品ID
    */
    public const ProductID = 'ProductID';
    /*
    * @Field Price
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 价值
    */
    public const Price = 'Price';
}

class StoreVoucherColumns
{
public  int $VoucherID;
   public  string $Title;
   public  int $IsDelete=0;
   public  int $RuleID=0;
   public  int $TimeAdd=0;
   public  int $ProductID=0;
   public  int $Price=0;
	public function toArray():array
	{
		return [
'VoucherID'=>$this->VoucherID,
    'Title'=>$this->Title,
    'IsDelete'=>$this->IsDelete,
    'RuleID'=>$this->RuleID,
    'TimeAdd'=>$this->TimeAdd,
    'ProductID'=>$this->ProductID,
    'Price'=>$this->Price,        ];
	}
}

class StoreVoucherRow
{
	public StoreVoucherColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'VoucherID' => $this->data->VoucherID,
        'Title' => $this->data->Title,
        'IsDelete' => $this->data->IsDelete,
        'RuleID' => $this->data->RuleID,
        'TimeAdd' => $this->data->TimeAdd,
        'ProductID' => $this->data->ProductID,
        'Price' => $this->data->Price, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new StoreVoucherColumns();
        isset($data['VoucherID']) && $this->data->VoucherID = (int)$data['VoucherID'];
           isset($data['Title']) && $this->data->Title = (string)$data['Title'];
           isset($data['IsDelete']) && $this->data->IsDelete = (int)$data['IsDelete'];
           isset($data['RuleID']) && $this->data->RuleID = (int)$data['RuleID'];
           isset($data['TimeAdd']) && $this->data->TimeAdd = (int)$data['TimeAdd'];
           isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['Price']) && $this->data->Price = (int)$data['Price'];
    }
}
?>